// YaP IRC - user class. Used in Channel form.
//Copyright (C) 2006  Pierre-Alain DAVID

//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU Lesser General Public
//License as published by the Free Software Foundation; either
//version 2.1 of the License, or (at your option) any later version.

//This library is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//Lesser General Public License for more details.

//You should have received a copy of the GNU Lesser General Public
//License along with this library; if not, write to the Free Software
//Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA


using System;

/// <summary>
/// Summary description for Class1
/// </summary>

namespace YaP.Library
{
    public class IrcUser : Object
    {
        public string complete;
        public bool IsHalfOp;
        public bool IsOpped;
        public bool IsVoiced;
        public string name;
        public string rank;
        public string rawname;
        public string wadd;

        public IrcUser(string nick)
        {
            string temprank = nick[0].ToString();
            IsOpped = false;
            IsVoiced = false;
            IsHalfOp = false;
            switch (temprank)
            {
                case "@":
                    name = nick.Substring(1);
                    rank = "@";
                    complete = nick;
                    IsOpped = true;
                    break;
                case "%":
                    name = nick.Substring(1);
                    complete = nick;
                    rank = "%";
                    IsHalfOp = true;
                    break;
                case "+":
                    name = nick.Substring(1);
                    complete = nick;
                    rank = "+";
                    IsVoiced = true;
                    break;
                default:
                    name = nick;
                    complete = name;
                    break;
            }
        }

        public IrcUser()
        {
            IsOpped = false;
            IsVoiced = false;
            IsHalfOp = false;
        }

        public string dyname
        {
            get { return name; }
            set
            {
                name = value;
                complete = rank + name;
            }
        }

        public override string ToString()
        {
            return complete;
        }
    }
}